/*
 * A class that defines a user, also keeps what level he/she's currently at.
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chalmers.se.tda367.model;

import javax.swing.ImageIcon;
import edu.chalmers.se.tda367.gui.panel.UserPanel;

/**
 *
 * @author pierrereimertz
 */
public class User {

    //Generic information
    private int classId;
    private int Id;
    private String name;
    private String password;
    private String imageUrl;
    private ImageIcon image;

    public ImageIcon getImage() {
        return image;
    }
    public static int globalId = 1;
    //Teacher Information
    private boolean isTeacher;
    //Student Information
    private int level = 1;
    //TODO Remove USerPanel from User
    private UserPanel panel;

    public User(String name, String password, String imageUrl, boolean isTeacher, int classId) {
        this.imageUrl = imageUrl;

        this.name = name;
        this.password = password;

        this.isTeacher = isTeacher;
        this.image = new ImageIcon(imageUrl);
        this.Id = globalId;
        this.classId = classId;
        globalId++;



    }

    public boolean getStatus() {
        return isTeacher;
    }

    public UserPanel getPanel() {
        return panel;
    }

    public String getName() {
        return name;
    }

    public String getPassword() {
        return password;
    }

    public void setLevel(int lvl) {
        this.level = lvl;
    }

    public int getLevel() {
        return level;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public String toDatabaseString() {
        String s = name + "," + password + "," + imageUrl + "," + isTeacher + "," + classId;
        return s;
    }

    public void setPanel(UserPanel p) {
        this.panel = p;
    }

    public boolean equal(User u) {
        if (this.Id != u.Id) {
            return false;
        }
        return true;
    }
}
